/*
 * author      : 吴中勤 
 * date        : 2019/3/22
 * description : TODO
 */

package org.wzq.learn.infrastructure.lib.trace.threadpool;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wzq.learn.infrastructure.lib.trace.ErrorReporter;

public final class ThreadExceptionHandler implements Thread.UncaughtExceptionHandler {
    private static final Logger logger = LoggerFactory.getLogger(ThreadExceptionHandler.class);

    public ThreadExceptionHandler() {
    }

    @Override
    public void uncaughtException(Thread t, Throwable e) {
        logger.error("ThreadExceptionHandler::uncaughtException", e);
        try {
            ErrorReporter.getInstance().sendAPIError(e);
        } catch (Exception ex) {
            logger.error("sentry服务异常", ex);
        }
    }
}
